package org.emergent.lucidity.lucifer.client;

import com.google.gwt.core.client.EntryPoint;

/**
 * Entry point classes define <code>onModuleLoad()</code>.
 */
public class Lucifer implements EntryPoint
{
    public void onModuleLoad() {
        doTheWildThingOnMyLeg();
    }

    public native String doTheWildThingOnMyLeg() /*-{
    try {
        var ivbytes = [
            "\u000b", "\u006c", "\u0046", "\u009b", "\u00f8", "\u005e", "\u00dd", "\u0042"].join();
        var keybytes = [
            "\u001f", "\u000a", "\u0064", "\u006d", "\u00b5", "\u0052", "\u00f5", "\u00e2",
            "\u00a8", "\u0072", "\u00b3", "\u00e5", "\u00e5", "\u0010", "\u0030", "\u0033"].join();
        var encbytes = [
            "\u00bf", "\u0032", "\u00de", "\u00d1", "\u00fd", "\u00e8", "\u00d5", "\u0068",
            "\u006a", "\u00b2", "\u0094", "\u00aa", "\u0038", "\u00d3", "\u0020", "\u00a0",
            "\u0082", "\u005c", "\u006e", "\u001f", "\u008c", "\u00af", "\u00a4", "\u00d2",
            "\u0025", "\u00f3", "\u00bb", "\u00de", "\u00ec", "\u00b1", "\u00e7", "\u004a",
            "\u00d5", "\u00ea", "\u00bf", "\u003c", "\u00c0", "\u006f", "\u00ce", "\u0037",
            "\u0092", "\u00cb", "\u0077", "\u004a", "\u0038", "\u009d", "\u00dc", "\u00c2",
            "\u00c4", "\u00b1", "\u00e9", "\u0085", "\u0055", "\u0046"].join();
        var expected = [
            "\u0000", "\u00fa", "\u0003", "\u00d0", "\u0096", "\u0063", "\u0073", "\u00b9",
            "\u007a", "\u0068", "\u0026", "\u00d3", "\u004e", "\u0031", "\u00f4", "\u00d7",
            "\u005f", "\u008c", "\u00b0", "\u007c", "\u001c", "\u00ef", "\u008c", "\u008f",
            "\u0008", "\u0034", "\u00bd", "\u0016", "\u006f", "\u0055", "\u009a", "\u007c",
            "\u009c", "\u004a", "\u00bb", "\u00fd", "\u008f", "\u000d", "\u0014", "\u0023",
            "\u0015", "\u0002", "\u0029", "\u0036", "\u001f", "\u00b3", "\u00fb", "\u0033",
            "\u0085", "\u00f2", "\u00ac", "\u004b", "\u0089", "\u0094"].join();

        var lucimpl = @org.emergent.lucidity.lucifer.client.LuciferImpl::getLuciferInstance()();

        var testresult = lucimpl.@org.emergent.lucidity.lucifer.client.LuciferImpl::decryptString(ZBLjava/lang/String;Ljava/lang/String;Ljava/lang/String;)(0,encbytes,keybytes,ivbytes);
        alert("test matches: " + (expected == testresult));
        keybytes = [
            "\u001f", "\u000a", "\u0064", "\u006d", "\u00b5", "\u0052", "\u00f5", "\u00e2",
            "\u001f", "\u000a", "\u0064", "\u006d", "\u00b5", "\u0052", "\u00f5", "\u00e2",
            "\u001f", "\u000a", "\u0064", "\u006d", "\u00b5", "\u0052", "\u00f5", "\u00e2",
            "\u00a8", "\u0072", "\u00b3", "\u00e5", "\u00e5", "\u0010", "\u0030", "\u0033"].join();
        testresult = lucimpl.@org.emergent.lucidity.lucifer.client.LuciferImpl::encryptString(ZBLjava/lang/String;Ljava/lang/String;Ljava/lang/String;)(0,encbytes,keybytes,ivbytes);
        alert("test matches: " + (expected == testresult));
        testresult = lucimpl.@org.emergent.lucidity.lucifer.client.LuciferImpl::inflateString(BLjava/lang/String;)(2,testinput);
        testresult = lucimpl.@org.emergent.lucidity.lucifer.client.LuciferImpl::deflateString(BLjava/lang/String;)(2,testinput);
        testresult = lucimpl.@org.emergent.lucidity.lucifer.client.LuciferImpl::hashString(BLjava/lang/String;)(2,testinput);
        lucimpl.@org.emergent.lucidity.lucifer.client.LuciferImpl::updateEntropy(I)(999);
        testresult = lucimpl.@org.emergent.lucidity.lucifer.client.LuciferImpl::randomString(IZ)(2,true);
    } catch (e) {
        alert( e );
    }
    }-*/;
}
